﻿<!DOCTYPE html>
<html ng-app>
  <head>
      <title>官网版本表单实例</title>

      <!--
       <script src="https://cdn.bootcss.com/angular.js/1.7.0/angular.min.js"></script>
         
        angular.js:14996 Error: [$controller:ctrlreg] http://errors.angularjs.org/1.7.0/$controller/ctrlreg?p0=Controller

          1.7 版本无法使用全局控制器
          -->
    <script src="http://code.angularjs.org/1.2.25/angular.min.js"></script>    
       
    <script type="text/javascript">
        function Controller($scope) {
            $scope.master = {};

            $scope.update = function (user) {
                $scope.master = angular.copy(user);
            };

            $scope.reset = function () {
                $scope.user = angular.copy($scope.master);
            };

            $scope.reset();
        };
    </script>
  </head>
  <body>
    <div ng-controller="Controller">
      <form novalidate class="simple-form">
        Name: <input type="text" ng-model="user.name" /><br />
        E-mail: <input type="email" ng-model="user.email" /><br />
        Gender: <input type="radio" ng-model="user.gender" value="male" />male
        <input type="radio" ng-model="user.gender" value="female" />female<br />
        <button ng-click="reset()">RESET</button>
        <button ng-click="update(user)">SAVE</button>
      </form>
      <pre>form =  {{user | json}} </pre>
      <pre>master =  {{master | json}} </pre>
    </div>
  </body>
</html>